package com.pp.mariage.server;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 
 * @author Pascal
 *
 */
public class MailTester {

	public static void main(String[] args) {
		System.out.println(isValidEmail("parant.pascal@gmail.com"));
		System.out.println(isValidEmail("parant-pascal@gmail.com"));
		System.out.println(isValidEmail("@gmail.com"));
		System.out.println(isValidEmail("1@gmail.com"));
		System.out.println(isValidEmail(".@gmail.com"));
		System.out.println(isValidEmail(".@gmail.com111"));
		System.out.println(isValidEmail(".@gmail.com111."));
		System.out.println(isValidEmail(".@gmail..com111."));
		System.out.println(isValidEmail("toto"));
	}

	private static boolean isValidEmail(String string) {
		System.out.print(string+"=>");
		Pattern pattern = Pattern.compile("^.+@.+\\..+$");
		Matcher matcher = pattern.matcher(string);
		return matcher.matches();
	}
}
